package com.itheima.service;

import com.itheima.dao.CleanHistoryDao;
import com.itheima.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @author: xy
 * @Date: create in 2020/3/7
 * @description:
 * @version: 1.0
 */

public class ClearImgJobService {

    @Autowired
    private CleanHistoryDao cleanHistoryDao;

    public void cleanHistory(){

//        创建日历对象
        Calendar calendar = Calendar.getInstance();
//        设置为去年
        calendar.add(Calendar.MONTH, -6);
//        转换日期
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

        String date = simpleDateFormat.format(calendar.getTime());

        cleanHistoryDao.deleteHistoury(date);
    }


}
